#!/bin/sh
HTMLFILE=$1
JSNAME=$2

sed -r "s:(<script[^>]*)/>:\\1></script>:" -i "$1"
sed "s: *></script>:></script>:" -i "$1"
sed -r "s:(<script.*)src=['\"]$2['\"].*</script>:\\1>\n###\n</script>\n:" -i "$1"

cat $1 | grep "###" -B 999999 | grep -v "###" > before.tmp
cat $1 | grep "###" -A 999999 | grep -v "###" > after.tmp
(cat before.tmp; cat "$2"; cat after.tmp)> newhtml.tmp
rm before.tmp after.tmp
mv newhtml.tmp "$1"



